

<template>
    <amis :amisjson="amisobj" id="btn"></amis>
    <div>
        <amis :amisjson="tableobj" id="table"></amis>
    </div>
</template>
<script setup lang="ts">

import { onMounted } from 'vue'

onMounted(() => {

})

const amisobj = {
    "type": "page",
    "body": {
        "type": "button-toolbar",
        "className": "block m-t",
        "buttons": [
            {
                "type": "button",
                "label": "新录数据",
                "actionType": "drawer",
                "drawer": {
                    "position": "right",
                    "title": "新录数据",
                    "body": {
                        "type": "form",
                        "api": "/api/generic/create?tableName=sys_dict",
                        "body": [
                            {
                                "type": "input-text",
                                "name": "source",
                                "label": "系统来源"
                            },
                            {
                                "type": "input-text",
                                "name": "key",
                                "label": "key值"
                            },
                            {
                                "type": "input-text",
                                "name": "value",
                                "label": "参数值"
                            },
                        ]
                    }
                }
            },
        ]
    }
}



const tableobj = {
    "title": "数据列表",
    "remark": "嘿，不保证数据准确性",
    "type": "page",
    "body": {
        "type": "crud",
        "draggable": true,
        "syncLocation": false,
        "api": "/api/generic/search?tableName=sys_dict",
        "keepItemSelectionOnPageChange": true,
        "autoGenerateFilter": true,
        "bulkActions": [
            {
                "type": "button",
                "label": "批量删除",
                "actionType": "ajax",
                "api": "/api/generic/delete?tableName=user&id=${ids|raw}",
                "confirmText": "确定要批量删除?"
            },
        ],
        "quickSaveApi": "/amis/api/mock2/sample/bulkUpdate",
        "quickSaveItemApi": "/api/generic/update?tableName=user&id${id}",
        "headerToolbar": [
            "bulkActions",

            {
                "type": "columns-toggler",
                "align": "right",
                "draggable": true
            },
            {
                "type": "drag-toggler",
                "align": "right"
            }
        ],
        "footerToolbar": [
            "statistics",
            "switch-per-page",
            "pagination"
        ],
        "columns": [
            {
                "name": "id",
                "label": "ID"
            },
            {
                "name": "source",
                "label": "系统来源"
            },
            {
                "name": "key",
                "label": "key值"
            },
            {
                "name": "value",
                "label": "参数值"
            },
            {
                "type": "operation",
                "label": "操作",
                "buttons": [
                    {
                        "label": "详情",
                        "type": "button",
                        "level": "link",
                        "actionType": "dialog",
                        "dialog": {
                            "title": "查看详情",
                            "body": {
                                "type": "form",
                                "body": [
                                    {
                                        "type": "input-text",
                                        "name": "source",
                                        "label": "系统来源"
                                    },
                                    {
                                        "type": "input-text",
                                        "name": "key",
                                        "label": "key值"
                                    },
                                    {
                                        "type": "input-text",
                                        "name": "value",
                                        "label": "参数值"
                                    },
                                ]
                            }
                        }
                    },
                    {
                        "label": "修改",
                        "type": "button",
                        "actionType": "drawer",
                        "drawer": {
                            "title": "详细信息",
                            "body": {
                                "type": "form",
                                "initApi": "/api/generic/findById?tableName=sys_dict&id=${id}",
                                "api": "post:/api/generic/update?tableName=sys_dict&id=${id}",
                                "body": [
                                    {
                                        "type": "input-text",
                                        "name": "source",
                                        "label": "系统来源"
                                    },
                                    {
                                        "type": "input-text",
                                        "name": "key",
                                        "label": "key值"
                                    },
                                    {
                                        "type": "input-text",
                                        "name": "value",
                                        "label": "参数值"
                                    },
                                ]
                            }
                        }
                    },
                    {
                        "type": "button",
                        "actionType": "ajax",
                        "label": "删除",
                        "confirmText": "您确认要删除?",
                        "api": "/api/generic/delete?tableName=sys_dict&id=$id",
                    }
                ]
            }
        ]
    }
}
</script>
  
<style ></style>
  